package com.gadgets.busi.bm01.task.hook;

import com.gadgets.busi.bm01.common.event.GadgetsBm01HttpFinishEvent;
import com.gadgets.busi.bm01.dto.TxtCopyTaskPercentDTO;
import org.springframework.stereotype.Component;

/**
 * The type Http finish hook.
 *
 * @author UncleXiu
 * @version V1.0.0
 * @data 2020 -09-21
 */
@Component
public class HttpFinishHook extends AbstractBm01TaskHook<GadgetsBm01HttpFinishEvent> {

    /**
     * 任务执行钩子
     *
     * @param event 事件信息
     */
    @Override
    public void excuteHook(GadgetsBm01HttpFinishEvent event) {
        logger.info("{}钩子开始调度",this.getClass().getName());
        if(null==event){
            logger.error("事件信息为空，无法执行任务钩子，执行被终止...");
        }else {
            TxtCopyTaskPercentDTO percentDTO = new TxtCopyTaskPercentDTO();
            percentDTO.setTaskNo(event.getTaskNo());
            percentDTO.setPercent(event.getPercent());
            copyTxtTaskRepository.updateTaskPercent(percentDTO);
        }
    }

}
